package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

/**
 * @Title: UserController
 * @Package: com.project.controller
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/6/29 - 13:47
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("user")
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String pwd, HttpServletRequest req){
        if ("java".equals(userName)&&"123".equals(pwd)){
            req.getSession().setAttribute("loginUser",userName);
            return "ok";
        }
        return "no";
    }
    @RequestMapping("add")
    public String add(String usaeName, @RequestParam("face") MultipartFile mf) throws IOException {
        String fileName=mf.getOriginalFilename();
        mf.transferTo(new File("D:\\JavaPlus\\javaWEB\\Interceptor\\src\\main\\resources\\static\\userface/"+fileName));
        return"ok";
    }
}
